<?php
//   +----------------------------------------------------------------------
//   | Copyright (c) 2015-2025 http://www.hdphp.cn All rights reserved.
//   | Licensed ( http://www.hdphp.cn/licenses/ )
//   | Author: Jack <sophia2152@qq.com>
//   | 官方网址: http://www.hdphp.cn
//   | 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用。
//   | 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
//   +----------------------------------------------------------------------
namespace app\common\services\system\config;

use app\common\services\BaseServices;
use app\common\dao\system\config\SystemStorageDao;
use hdphp\traits\ServicesTrait;

/**
 * Class：SystemStorageServices
 * 创建人：Jack
 * 创建时间：2024/1/29 17:02
 * @package app\common\services\system\config
 * @mixin SystemStorageDao
 */
class SystemStorageServices extends BaseServices
{
    use ServicesTrait;

    /**
     * 构造函数
     * @param SystemStorageDao $dao
     */
    public function __construct(SystemStorageDao $dao)
    {
        $this->dao = $dao;
    }



    /**
     * 注释：获取云存储配置
     * 创建人：Jack
     * 创建时间：2024/1/29 17:03
     * @param int $type
     * @return array|string[]
     */
    public function getConfig(int $type)
    {
        $res = ['name' => '', 'region' => '', 'domain' => ''];
        try {
            $config = $this->dao->get(['type' => $type, 'status' => 1, 'is_delete' => 0]);
            if ($config) {
                return ['name' => $config->name, 'region' => $config->region, 'domain' => $config->domain];
            }
        } catch (\Throwable $e) {

        }
        return $res;
    }


}
